package com.dachuang.canjiren.controller;


import com.dachuang.canjiren.service.CommentService;
import com.dachuang.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2020-07-27
 */
@RestController
@RequestMapping("/canjiren/comment")
public class CommentController {

    @Autowired
    private CommentService commentService;

    /**
     * 志愿者评论
     * @param comments
     * @param mainId
     * @param userId
     * @param volunteerId
     * @return
     */
    @GetMapping(value = "insert")
    R insert(
            @RequestParam(value = "comments", required = false) String comments,
            @RequestParam(value = "mainId", required = false) Integer mainId,
            @RequestParam(value = "userId", required = false) Integer userId,
            @RequestParam(value = "volunteerId", required = false) Integer volunteerId) {
        return commentService.insertComment(comments, mainId, userId, volunteerId);
    }

    /**
     * 志愿者评论展示
     * @param volunteerId
     * @return
     */
    @GetMapping(value = "list")
    R list(@RequestParam(value = "volunteerId", required = false) Integer volunteerId) {
        return commentService.selectCommentList(volunteerId);
    }
}

